<template>
  <el-container direction="vertical">
    <SearchForm :columns="formColumn" @search="search" @reset="search" />
		<el-header>
			<div class="left-panel">
				<el-button type="primary"  @click="tiaozhuang" >
					新增班级
				</el-button>
				<el-button icon="el-icon-download" class="mr10">
					导出
				</el-button>
				<scFileImport
  		    ref="scFileImport"
  		    class="mr10"
  		    :apiObj="importExcel.apiObj"
  		    :templateUrl="importExcel.templateUrl"
  		  >
  		    <template #default="{open}">
  		      <el-button type="primary" @click="open">
  		        导入班级
  		      </el-button>
    	    </template>
    		</scFileImport>
				<el-button @click="batchOpenClass">
					批量开班
				</el-button>
				<el-button @click="batchCloseClass">
					批量停班
				</el-button>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable
				ref="table"
				tableName="studentList"
				v-bind="list"
				row-key="id"
				stripe
			>
				<el-table-column type="selection" width="50"></el-table-column>
				<template #name="scope">
					<el-link
						:underline="false"
						type="primary"
						:href="`#/student/redact/${scope.row.studentId}`"
						>{{ scope.row.name }}</el-link
					>
				</template>
				<el-table-column
					label="操作"
					width="255"
					fixed="right"
					align="center"
				>
					<template #default="scope">
						<el-button
							type="primary"
							plain
							size="small"
							@click="deleteDetail(scope.row)"
							>删除</el-button>
						<el-button
							type="primary"
							plain
							size="small"
							@click="copyDetail(scope.row)"
							>大纲</el-button>
						<!-- <el-button
							plain
							size="small"
							@click="stopUsing(scope.row)"
							>名单</el-button> -->
							<el-button
							plain
							size="small"
							@click="editDetail(scope.row)"
							>排课</el-button>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
  </el-container>
</template>
<script>
import SearchForm from "@/components/SearchForm/index.vue";
import { formColumn, column} from "./date";
import scFileImport from '@/components/scFileImport';
import { ElMessage, ElMessageBox } from 'element-plus'
export default {
	components: { SearchForm, scFileImport	},
  data() {
    return {
    	formColumn,
    	list: {
				apiObj: this.$API.student.classManagementList,
				params: {},
				column,
			},
			importExcel: {
			templateUrl: 'https://binaries.templates.cdn.office.net/support/templates/zh-cn/tf45048037_win32.xltm',
				apiObj: {
					post: () => Promise.resolve([])
				}
			}
		}
  },
  methods: {
		search(searchParams) {
			const params = Object.assign({}, this.list.params, searchParams);
			this.$refs.table.reload(params);
		},
		tiaozhuang(){
			this.$router.push({
				path: "/teach/addclass"
			})
		},
		deleteDetail(row) {
			console.log(row, "我是删除");
			ElMessageBox.confirm('确定要删除该课程?','提示',{
  		    confirmButtonText: '确定',
  		    cancelButtonText: '取消',
  		    type: 'warning',
  		  }).then(() => {})
		},
		copyDetail(row) {
			console.log(row, "我是大纲");
			this.$router.push({
				path: "/teach/addclass"
			})
		},
		stopUsing(row) {
			console.log(row, "我是名单");
			this.$router.push({
				path: "/teach/class/list"
			})
		},
		editDetail(row) {
			console.log(row, "我是排课");
			this.$router.push({
				path: "/teach/class/arrang"
			})
		},
		importStundentsExcel() {
      this.$refs.scFileImport.open();
    },
		// 批量开班
		batchOpenClass()  {
			if (this.$refs.table.tableSelection.length > 0) {
				ElMessageBox.confirm(
    		 	'是否批量开班?',
    		 	'批量开班',
    		 	{
    		 	  confirmButtonText: '确定',
    		 	  cancelButtonText: '取消',
						buttonSize: "small"
    		 	}
 				).then(() => {})
    		.catch(() => {})
			}else{
				ElMessage({
					message: "请选择班级",
					type: "warning"
				})
			}
		},
		// 批量停班
		batchCloseClass()  {
			if (this.$refs.table.tableSelection.length > 0) {
				ElMessageBox.confirm(
    		 	'是否批量停班?',
    		 	'批量开班',
    		 	{
    		 	  confirmButtonText: '确定',
    		 	  cancelButtonText: '取消',
						buttonSize: "small"
    		 	}
 				).then(() => {})
    		.catch(() => {})
			}else{
				ElMessage({
					message: "请选择班级",
					type: "warning"
				})
			}
		}
  },
}
</script>
<style lang="scss" scoped>
.mr10 {
  margin-right: 10px;
}
</style>